<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>数据分页</title>
    <link rel="stylesheet"
          th:href="@{/login/css/bootstrap.min.css}">
</head>
<body class="container">
<br/>
<h1>用户列表</h1>
<br/><br/>
<div class="with:80%">
    <table class="table table-hover">
        <thead>
        <tr>
            <th>#</th>
            <th>Name</th> <th>Phone</th> <th>Edit</th> <th>Delete</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="user : ${users}">
            <th scope="row" th:text="${userStat.index + 1}">1</th>
            <td th:text="${user.username}"></td>
            <td th:text="${user.phone}"></td>
            <td><a onclick="return confirm('确定修改吗？')" th:href="@{/toEdit(id=${user.id})}">edit</a></td>
            <td><a onclick="return confirm('确定删除吗？')" th:href="@{/delete(id=${user.id})}">delete</a></td>
        </tr>
        </tbody>
    </table>
</div>
<div class="form-group">
    <div class="col-sm-2 control-label">
        <a th:href="@{/toAdd}" class="btn btn-info">add</a>
    </div>
</div>
<div class="form-group">
    总条数：<span th:text="${users.totalElements}"></span>&nbsp;&nbsp;
    总页数：<span th:text="${users.totalPages}"></span>&nbsp;&nbsp;
    当前页码：<span th:text="${users.number}+1"></span>
</div>
<div class="modal-footer no-margin-top">
    <ul class="pagination pull-right no-margin">
        <li>
            <a th:href="@{/toPaging}">首页</a>&nbsp;&nbsp;
        </li>
        <li th:if="${not users.first}">
            <a th:href="@{/toPaging(pageNum=${users.number - 1})}" th:text="上一页"></a>&nbsp;&nbsp;
        </li>
        <!-- 中间页 -->
        <li th:each="n:${#numbers.sequence(0, users.totalPages - 1)}">
            <a th:href="@{/toPaging(pageNum=${n})}" th:text="${n + 1}" th:if="${n ne users.number}"></a>
            <a th:href="@{/toPaging(pageNum=${n})}" th:text="${n + 1}" th:if="${n eq users.number}"
            th:style="'font-weight:bold;background: #6faed9;'"></a>
        </li>&nbsp;&nbsp;
        <li th:if="${not users.last}">
            <a th:href="@{/toPaging(pageNum=${users.number + 1})}" th:text="下一页"></a>&nbsp;&nbsp;
        </li>
        <li>
            <a th:href="@{/toPaging(pageNum=${users.totalPages - 1})}">尾页</a>
        </li>
    </ul>
</div>
</body>
</html>
